package com.kizuki.jvm;

import java.util.ArrayList;
import java.util.List;

public class TestOOM {

    // -Xms1m -Xmx8m -XX:+HeapDumpOnOutOfMemoryError

    /**
     * java.lang.OutOfMemoryError: Java heap space
     * Dumping heap to java_pid5600.hprof ...
     * Heap dump file created [8302003 bytes in 0.019 secs]
     * Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
     * 	at com.kizuki.jvm.TestOOM.main(TestOOM.java:21)
     */
    public static void main(String[] args) {
        List<int[]> list = new ArrayList<>();

        while(true) {
            list.add(new int[100]);
        }
    }

    /**
     * 1. cmd D:\LearnJava\Test>jhat java_pid5600.hprof 访问 http://localhost:7000/
     * 2. JProfiler 软件
     */

}
